package com.sk.bilibili.handler;

import com.sk.bilibili.bean.Member;
import com.sk.bilibili.bean.MemberExtend;
import com.sk.bilibili.property.BiliBiliProperty;
import com.sk.bilibili.service.MemberExtendService;
import com.sk.bilibili.service.PendantService;
import com.sk.bilibili.service.SkinService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;

/**
 * @author 邵康
 * @date 2021/12/19 9:32
 * 可以 与 MemberNumHandler   合并 不过业务上不太好  看 类命名  不该合并
 */
@Component
public class MemberPostValueHandler implements PostValueHandler<Member> {

    // 这里引入数据库操作 必须延时引入
    @Lazy
    @Autowired
    private PendantService pendantService;
    @Lazy
    @Autowired
    private SkinService skinService;
    @Autowired
    private BiliBiliProperty biliBiliProperty;

    @Override
    public void postHandle(Member member) {
        member.getExtra().put("pendant",pendantService.getById(member.getPendantId()));
        member.getExtra().addExtra(skinService.getById(member.getSkinId()));
        member.getExtra().put("fullExperience",biliBiliProperty.getExperiences()[member.getGrade()]);
    }

}
